package com.mybatis.example.plugs;


import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;

import java.util.Properties;

@Intercepts(value={
        @Signature( type= Executor.class,method = "query",args = {MappedStatement.class,Object.class, RowBounds.class, ResultHandler.class})
})
public class MyPlugs implements Interceptor {

    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        Object object =  invocation.proceed();
        System.out.println("我的插件");
        return object;
    }



    @Override
    public void setProperties(Properties properties) {

        properties.forEach((k,v)->{
            System.out.printf("key=%s,value=%s\n", k,v);
        });

    }
}
